package com.pigcloud.sop.bridge;

import com.pigcloud.sop.bridge.route.NacosRegistryListener;
import com.pigcloud.sop.gatewaycommon.gateway.controller.ConfigChannelController;
import com.pigcloud.sop.gatewaycommon.gateway.controller.GatewayController;
import com.pigcloud.sop.gatewaycommon.route.RegistryListener;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.codec.ServerCodecConfigurer;

@Configuration
public class SopRegisterAutoConfiguration {
    /**
     * 微服务路由加载
     */
    @Bean
    RegistryListener registryListenerNacos() {
        return new NacosRegistryListener();
    }

    /**
     * 网关 处理签名错误返回
     * @return
     */
    @Bean
    @ConditionalOnMissingBean(name = "gatewayController")
    public GatewayController reactiveGatewayController() {
        return new GatewayController();
    }
    @Bean
    @ConditionalOnMissingBean(name = "configChannelController")
    public ConfigChannelController configChannelController(ServerCodecConfigurer codecConfigurer) {
        return new ConfigChannelController(codecConfigurer);
    }
}
